package org.mx.dal.entity;

import org.mx.dal.annotation.ElasticField;

import com.fasterxml.jackson.annotation.JsonIgnore;

import co.elastic.clients.elasticsearch._types.mapping.Property.Kind;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 描述： 基于Elasticsearch实现的基础类实体
 *
 * @author John.Peng
 * Date time 2018/4/1 上午8:41
 */
@ToString
public class ElasticBaseEntity implements Base {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1242410808768776124L;
	@ElasticField
    private @Getter @Setter String id, operator; // ID、操作者
    @ElasticField(type = Kind.Long)
    private @Getter @Setter long createdTime, updatedTime; // 创建时间、更新时间
    @ElasticField(type = Kind.Long)
    private int valid = 1; // 是否有效

    // 存储搜索结果的命中分数
    private @Getter @Setter @JsonIgnore double score = 0.0f;
    // 存储搜索结果中可能存在的命中高亮字段（仅针对CONTAIN搜索条件字段）
    private @Getter @JsonIgnore Map<String, List<String>> highlights = new HashMap<>();

    /**
     * {@inheritDoc}
     *
     * @see Base#getValid()
     */
    @Override
    public int getValid() {
        return valid;
    }

    /**
     * {@inheritDoc}
     *
     * @see Base#setValid(int)
     */
    @Override
    public void setValid(int valid) {
        this.valid = valid;
    }
}
